package ua.com.infinite.mobile.db;

import ua.com.infinite.mobile.contentprovider.InfiniteContentProvider;
import android.content.ContentResolver;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;

public class TableNews {
	public static final String TABLE_NAME = "news";
	public static final String COLUMN_USER_ID = "user_id";
	public static final String COLUMN_ID = "_id";
	public static final String COLUMN_TYPE = "type";
	public static final String COLUMN_POSTER_ICON = "poster_icon";
	public static final String COLUMN_POSTER_NAME = "poster_name";
	public static final String COLUMN_POSTER_ID = "poster_id";
	public static final String COLUMN_POST_TITLE = "post_title";
	public static final String COLUMN_POST_TEXT = "post_text";
	public static final String COLUMN_POST_IMGS = "post_img";
	public static final String COLUMN_DATE = "date";
	
	public static final Uri CONTENT_URI = Uri.parse("content://" + InfiniteContentProvider.AUTHORITY + "/" + TABLE_NAME);

	public static final String CONTENT_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + "/news";
	public static final String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/new";

	public static final String CREATE_TABLE = "create table " + TABLE_NAME
			+ "(" 
			+ COLUMN_ID + " integer primary key, " 
			+ COLUMN_USER_ID+ " integer not null, "
			+ COLUMN_TYPE+" text, "
			+ COLUMN_POSTER_ICON+" text, "
			+ COLUMN_POSTER_NAME+" text, "
			+ COLUMN_POSTER_ID+" int, "
			+ COLUMN_POST_TITLE+" text, "
			+ COLUMN_POST_TEXT+" text, "
			+ COLUMN_POST_IMGS+" text, "
			+ COLUMN_DATE+" text"
			+");";

	public static void onCreate(SQLiteDatabase db) {
		try {
			db.execSQL(CREATE_TABLE);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
